import 'package:erp/EventBus/EventBus.dart';
import 'package:erp/Events/Index.dart';
import 'package:erp/UI/CodeResources/Screen.dart';
import 'package:erp/global.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_statusbar_manager/flutter_statusbar_manager.dart';
import 'package:shared_preferences/shared_preferences.dart';

import "./UI/CodeResources/Colors.dart";
import './UI/CodeResources/Localization.dart';
import "./UI/Routes.dart";

void main() async {
  setFullScreen();
  applyLogger();
  globalPreferences = await SharedPreferences.getInstance();
  registerBackgroundEvents();

  runApp(
      MaterialApp(
        /**
         * Support localizations
         * */
        supportedLocales: localizations,
        localizationsDelegates: [
          const AppLocalizationDelegate(),
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
        ],
        localeResolutionCallback: (locale, available) {
          var availables = available.where((item) =>
          item.languageCode == locale.languageCode);

          return availables.length > 0 ? availables.first : available.first;
        },


        theme: ThemeData(
          primaryColor: themeColor,
//        fontFamily: AppLocalizations
//            .of(context)
//            .fontFamilyOfMain,
          fontFamily: "ukij-cjk",
          textSelectionHandleColor: themeColor,
        ),


        routes: PagesRouter.routes,
        initialRoute: PagesRouter.signIn,
      )
  );
}

